﻿using MediatR;
using SlaughterItem.Common.Domains.SetUpScale;
using SlaughterItem.Common.Dtos;
using SlaughterItem.Common.Infrastructures.Interfaces;
using SlaughterItem.Enum;

namespace SlaughterItem.API.Application.Commands.Week02.POOK.Whitepork
{
    public class ScaleDataHandler : IRequestHandler<ScaleDataCommand, Result>
    {
        public ScaleDataHandler(IBaseRepositoryGet<scaleContexts> scaleContextRepository)
        {
            ScaleContextRepository = scaleContextRepository;
        }

        public IBaseRepositoryGet<scaleContexts> ScaleContextRepository { get; set; }
        public async Task<Result> Handle(ScaleDataCommand request, CancellationToken cancellationToken)
        {
            var result=new Result() { Code=(int)CommonErrorCode.Search};
            var list = ScaleContextRepository.GetAll().Where(x => x.IsScaleDelete == false).ToList();
            result.Data = list;
            result.Code = (int)CommonErrorCode.Success;
            return result;
        }
    }
}
